<?php

class mf extends tsApp{

	private $messagemb_doman='http://m.5c.com.cn/api/send/index.php'; 
	private $redis_on = 0;//redis是否开启，0不开启，1开启
	 


	public function __construct($db){
 		parent::__construct($db);
	}
	
	//获取是否节假日
	public function isholiday($dt){
		$tm=date('Ymd',$dt);
		$url=$this->holidayapi.$tm;
		$ch = curl_init();
		$header=array('apikey:eed45fd83c2556b83e912e82cc5f5595');
		curl_setopt($ch, CURLOPT_HTTPHEADER  , $header);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch , CURLOPT_URL , $url);
		$ot = curl_exec($ch);
		return $ot;
	} 
 
	//日程
	public function caSchedule( $schid ){
		$key = "gymchina_schedule:$schid";
		R()->delete( $key );
		if( !R()->exists( $key ) ){
			$schedule = $this->find('schedule',array('schid'=>$schid));  
			R()->hMset( $key,$schedule );
			R()->expireAt( $key,time()+3600 );
			return $schedule;
		}
		return R()->hGetAll($key);
	
	}
	
	//日程
	public function caPerSchedule( $sid ){
		$key = "gymchina_per_schedule:$sid";
		R()->delete( $key );
		if( !R()->exists( $key ) ){
			$schedule = $this->find('pers_schedule',array('pschid'=>$sid));  
			R()->hMset( $key,$schedule );
			R()->expireAt( $key,time()+3600 );
			return $schedule;
		}
		return R()->hGetAll($key);
	}
  
	public function caScheRoom( $rid ){
		$key = "gymchina_sche_room:$rid";
		R()->delete( $key );
		if( !R()->exists( $key ) ){
			$room = $this->find('broom',array( 'rid' => $rid ));  
			R()->hMset( $key,$room );
			R()->expireAt( $key,time()+3600 );
			return $room;
		}
		return R()->hGetAll($key);
	}
 

}
